#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
typedef long long LL;
using namespace std;

int a[12];
int res[12];
int main(int argc, char** argv) {
#ifdef hai
    freopen("in.txt", "r", stdin);
#endif
    int n;
    while(cin>>n) {
        memset(a, 0, sizeof(a));
        memset(res, 0, sizeof(res));
        int mark=1;
        for (int i=1; i<=9; ++i) {
            scanf("%d", a+i);
            if (a[i]<a[mark]) mark=i;
        }
        if (n<a[mark]) {
            cout<<-1<<endl;
            continue;
        }
        res[mark]=n/a[mark];
        int les=n%a[mark];
        int l=mark, r=10;
        while (l<10) {
            if (res[l]==0) {
                l++;
                continue;
            }
            int z=les+a[l];
            res[l]-=1;
            int t=l;
            for (int i=l; i<r; ++i) {
                if (a[i]<=z) t=i;
            }
            res[t]++;
            if (t==l) l++;
            les=z-a[t];
        }
        for (int i=9; i>=1; --i) {
            while (res[i]--) printf("%d", i);
        }
        printf("\n");
    }
    return 0;
}
